﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
using System.IO;

public partial class CMS_ViewListBorder : System.Web.UI.Page
{
    Usas.BLL.Cms.cmsBorder bo = new Usas.BLL.Cms.cmsBorder();
    Usas.Common.Cms.CurrentInfo cinfo = new Usas.Common.Cms.CurrentInfo();
    Usas.Common.Cms.Role ro = new Usas.Common.Cms.Role();
    Usas.BLL.Cms.AspPager ap = new Usas.BLL.Cms.AspPager();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                ViewBind();

                MasterPage_MasterPage_CMS mmc = (MasterPage_MasterPage_CMS)this.Page.Master;
                mmc.ManagerHover();
            }
            catch
            { }
        }
    }


    private void ViewBind()
    {
        RouterBar1.IntiBar(CMS_Control_RouterBar.ShowMode.Type, Convert.ToInt32(Request["id"]), new ArrayList());
       
        CMS_Control_CacheView ctop = (CMS_Control_CacheView)Page.LoadControl("~/CMS/Control/CacheView.ascx");
        ctop.GetCacheView(CMS_Control_CacheView.ShowMode.GetTop, 7, "111" + Request["id"], cinfo.GetEmpRole(), "精华主题", 1, RouterBar1.BarText, false, false, -1, "");
        ViewContent1.Controls.Add(ctop);

        DataTable dt = ap.GetBorderTableBySetting(ro.GetSelfSettingRole(), "Del <> 1 and TypeId=" + Request["id"], 1, -1, "BorderOrder");
        string temp = System.Configuration.ConfigurationManager.AppSettings["UsasInformationPath"].ToString() + "Pic\\";

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            CMS_Control_CacheView ccc = (CMS_Control_CacheView)Page.LoadControl("~/CMS/Control/CacheView.ascx");
            bool edit = Convert.ToInt32(dt.Rows[i]["edit"]) > 0 ? true : false;
            bool view = Convert.ToInt32(dt.Rows[i]["view"]) > 0 ? true : false;

         

            if (view)
            {
                FileInfo fn = new FileInfo(temp + dt.Rows[i]["ImgFile"].ToString());
                if (fn.Exists)
                {
                    ccc.GetCacheView(CMS_Control_CacheView.ShowMode.Border, 7, dt.Rows[i]["BorderId"].ToString(), cinfo.GetEmpRole(),
                        dt.Rows[i]["BorderName"].ToString(), 1, RouterBar1.BarText, edit, false, -1, i % 2 == 0 ?
                        "l," + System.Configuration.ConfigurationManager.AppSettings["UsasInformationIIS"].ToString() + "Pic/" + fn.Name
                        : "r," + System.Configuration.ConfigurationManager.AppSettings["UsasInformationIIS"].ToString() + "Pic/" + fn.Name);
                }
                else
                {
                    ccc.GetCacheView(CMS_Control_CacheView.ShowMode.Border, 7, dt.Rows[i]["BorderId"].ToString(), cinfo.GetEmpRole(), dt.Rows[i]["BorderName"].ToString(), 1, RouterBar1.BarText, edit, false, -1, "");
                }
                ViewContent1.Controls.Add(ccc);
            }

        }
    }
}
